<template>
	<view class="all">
		<view class="mohuimg">
			<image src="../../static/background/sky2.jpg" mode="aspectFill"></image>
		</view>
		<view class="topbox" @click="gotoModify()">
			<image class="touxiang" :src="myInfo.portraitURL"></image>
			<view class="msgbox">
				<view class="namebox">
					<view class="name">{{myInfo.nickname}}</view>
					<image class="image" v-if="myInfo.gender == '女'" src="../../static/woman.png"></image>
					<image class="image" v-if="myInfo.gender == '男'" src="../../static/man.png"></image>
				</view>
				<view class="telbox">
					<view>手机号码：</view>
					<view>{{myInfo.userId}}</view>
				</view>
				<view class="unibox">
					<view>目标院校：</view>
					<view>{{myInfo.school}}</view>
				</view>
				<view class="majbox">
					<view>目标专业：</view>
					<view>{{myInfo.major}}</view>
				</view>
			</view>
		</view>
		<view style="border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;
		height: 50rpx;background-color: #FFFFFF;position: relative;top:-320rpx">
		</view>
		<view class="titlebox">
			<view class="trade">
				<view class="texts" :class="curr==0?'active':''" data-index="0" @tap="changeBar">我的圈子</view>
				<view class="texts" :class="curr==1?'active':''" data-index="1" @tap="changeBar">我的帖子</view>
			</view>
			<view v-for="(item,index) in top_tab" :key='index' :id="index" class="uni-tab-item" @click="tabTap">
				<text class="uni-tab-item-title"
					:class="toptab==index ? 'uni-tab-item-title-active' : ''">{{item}}</text>
			</view>
		</view>
		<view class="bigbox">
			<swiper style="height:100vh" :current="curr" @change="setCurr">
				<swiper-item class="swiper-item2">
					<scroll-view class="scroll-view1" scroll-y="true" style="height: auto"
						@scrolltolower.stop.prevent="lower">
						<view class="groupbox" v-for="(item,index) in myInfo.attentionList" :key="index" @click="gotogroup(item)">
							<view class="logobox">
								<image :src="item.schoolPortraitURL"></image>
							</view>
							<view class="universityname">
								<text>{{item.school}}</text>
							</view>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item1">
					<scroll-view class="scroll-view1" scroll-y="true" style="height: auto"
						@scrolltolower.stop.prevent="lower">
						<view class="my_evaluate" v-for="(item,index) in myReleaseList" :key="index"
							@click.stop="dynamic(item)">
							<!--这里的list要换成获取到的数据-->
							<view class="title">
								<text>{{item.title}}</text>
								<!--帖子标题-->
							</view>
							<view class="headbox">
								<view class="head_image" @click.stop="getUser(item)">
									<!-- <image :src="item.user.avatar"></image> -->
									<image :src="item.portrait"></image>
									<!--头像-->
								</view>
								<view class="headcenter">
									<!-- <view class="head_name" @click.stop="getUser(item)">{{item.user.userName}}</view>
									<view class="head_time">{{renderTimeYMDHMS(item.postTime)}}</view> -->
									<view class="head_name" @click.stop="getUser(item)">{{item.nickname}}</view>
									<view class="head_time">{{item.createTime}}</view>
								</view>
							</view>
							<view class="content">
								<text>
									{{item.content}}
								</text>
							</view>
							<view v-if="item.topicPictures === null">
							</view>
							<view v-if="item.topicPictures !== null">
								<view class="dynamicimage" v-if="item.topicPictures.length === 1">
									<image class="image" :src="pic" v-for="(pic, index) in item.topicPictures"
										mode="aspectFill" :key="index"></image>
								</view>
								<view class="dynamicimage2" v-if="item.topicPictures.length === 2">
									<image class="image2" :src="pic" v-for="(pic, index) in item.topicPictures"
										mode="aspectFill" :key="index"></image>
								</view>
								<view class="dynamicimage4" v-if="item.topicPictures.length === 4">
									<image class="image4" :src="pic" v-for="(pic, index) in item.topicPictures"
										mode="aspectFill" :key="index"></image>
								</view>
								<view class="dynamicimage3" v-if="item.topicPictures.length === 3 || item.topicPictures.length === 5 || item.topicPictures.length === 6 || 
							item.topicPictures.length === 7 || item.topicPictures.length === 8 || item.topicPictures.length === 9">
									<image class="image3" :src="pic" v-for="(pic, index) in item.topicPictures"
										mode="aspectFill" :key="index"></image>
								</view>
							</view>
				
							<view class="tagbox">
								<!-- <view class="tag" v-for="(a, index) in item.postTag" :key="index"
									:style="{'background-color':colorlists[index]}">
									#{{a}}
								</view> -->
				
								<view class="tag" v-for="(a,index) in item.tag" :key="index"
									:style="{'background-color':colorlists[index]}">
									{{a}}
								</view>
							</view>
							
							<view class="likecmt">
								<view class="likebox">
									<view @click.stop="likeNew(item)" hover-stay-time="1000">
										<image v-if="item.isLike == false"
											src="../../static/likefalseicon.png"></image>
										<image v-if="item.isLike == true"
											src="../../static/liketrueicon.png"></image>
									</view>
									<text>{{item.thumpUp}}</text><!-- {{item.postLikeNum}} -->
								</view>
								<view class="cmtbox">
									<image src="../../static/likeorcmt/resoicon.png"></image>
									<text>{{item.recommendNum}}</text>
								</view>
							</view>
							
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad() {
			var userId = getApp().globalData.userId
			this.userId = getApp().globalData.userId
			console.log(this.userId)

		},
		onShow() {
			this.getMyInfo(this.userId)
			this.getMyPost(this.userId)
		},
		data() {
			return {
				myReleaseList: [],
				userId: "",
				myInfo: {},
				curr: 0,
				sex: 1,
				tel: 12345678901,
				university: "南京航空航天大学",
				major: "计算机科学与技术",
				testlist1: [1, 2, 3, 4, 5, 6],
				photolist: [1, 2, 3, 4],
				isLike: 0,
				taglist: [1, 2],
				colorlists: [
					'rgb(243, 2, 168)',
					'rgb(16, 195, 195)',
					'rgb(84, 2, 255)',
					'hsl(12, 90%, 34%)',
					'hsl(138, 24%, 48%)',
					'rgb(232, 13, 131)',
					'hsl(0, 99%, 34%)',
					'rgb(226, 166, 198)',
					'hsl(278, 17%, 66%)',
					'rgb(234, 199, 12)',
					'blueviolet'
				],
				likenumber: 10
			}
		},
		methods: {
			getMyInfo(userId) {
				uni.request({
				    url: this.baseurl + '/getMyMessage',
					data: {
						userId: userId
					},
				    success: (res) => {
						this.myInfo = res.data;
						console.log(res.data);
				    }
				});
			},
			//获取我的帖子
			getMyPost(userId) {
				uni.request({
				    url: this.baseurl + '/getMyReleaseList',
					data: {
						userId: userId
					},
				    success: (res) => {
						this.myReleaseList = res.data.topicList;
						console.log(this.myReleaseList);
						for(var i = 0; i < this.myReleaseList.length; i++) {
							this.myReleaseList[i].isLike = false
						}
				    }
				});
			},
			gotogroup(item) {
				uni.navigateTo({
					url: "../circle/UniversityMsg" + "?groupId=" + item.groupId
				})
			},
			likeNew(item){
				if(item.isLike == false){
					item.isLike = true;
					item.thumpUp++;
				}
				else{
					item.isLike = false;
					item.thumpUp--;
				}
			},
			dynamic(item) {
				console.log('你点击了动态')
				console.log(item)
				uni.navigateTo({
					url: '../post/postdetail'
						+ '?topicId='
						+ item.topicId
					
				})
			},
			//修改时间格式：年月日时分秒
			renderTimeYMDHMS(date) {
				var dateee = new Date(date).toJSON();
				return new Date(+new Date(dateee) + 8 * 3600 * 1000)
					.toISOString()
					.replace(/T/g, ' ')
					.replace(/\.[\d]{3}Z/, '')
			},
			gotoModify() {
				uni.navigateTo({
					url: "./modify"
				})
			},
			changeBar(e) {
				// console.log(e.detail.current)
				let thisCurr = e.detail.current || e.currentTarget.dataset.index || 0;
				// console.log(thisCurr)
				this.curr = thisCurr;
			},
			setCurr(e) {
				// console.log(e.detail.current)
				let thisCurr = e.detail.current || e.currentTarget.dataset.index || 0;
				// console.log(thisCurr)
				this.curr = thisCurr;

				// if (this.curr == 0) {
				// 	//动态最新
				// 	this.dynamicNewPageNumber = 0,
				// 	this.dynamicNewPageSize = 10,
				// 	this.dynamicNewStatus = 'more',
				// 	this.dynamicNewUpLoadData =  [],
				// 	this.dynamicNewListData = [],
				// 	this.dynamicNewPageLoad()
				// }
				// if (this.curr == 1) {
				// 	//动态最热
				// 	this.dynamicHotPageNumber = 0,
				// 	this.dynamicHotPageSize = 10,
				// 	this.dynamicHotStatus = 'more',
				// 	this.dynamicHotUpLoadData = [],
				// 	this.dynamicHotListData = [],
				// 	this.dynamicHotPageLoad()
				// }
				// if (this.curr == 2) {
				// 	//动态关注
				// 	this.dynamicMyPageNumber = 0,
				// 	this.dynamicMyPageSize = 10,
				// 	this.dynamicMyStatus = 'more',
				// 	this.dynamicMyUpLoadData = [],
				// 	this.dynamicMyListData = [],
				// 	this.dynamicMyPageLoad()
				// }
			},
		}

	}
</script>

<style lang="scss">
	.all {
		height: 100vh;

		.mohuimg {
			background-color: #007AFF;
			width: 100%;
			height: 480rpx;
			overflow: hidden;
		}

		.mohuimg>image {
			width: 100%;
			filter: blur(5px);
		}

		.topbox {
			display: flex;
			height: 300rpx;
			position: relative;
			top: -380rpx;
			align-items: center;

			.touxiang {
				margin-left: 50rpx;
				height: 180rpx;
				width: 180rpx;
				border-radius: 100rpx;
			}

			.msgbox {
				margin-left: 20rpx;
				width: 480rpx;
				display: flex;
				flex-direction: column;
				//background-color: #3F536E;
				height: 280rpx;
				justify-content: space-around;

				.namebox {
					display: flex;
					flex-direction: row;
					//background-color: #007AFF;
					justify-content: center;
					align-items: center;

					.name {
						margin-left: 30rpx;
						color: #FFFFFF;
						font-size: 50rpx;
						font-weight: bold;
					}

					.image {
						margin-left: 30rpx;
						width: 50rpx;
						height: 50rpx;
					}
				}

				.telbox {
					display: flex;
					flex-direction: row;
					justify-content: center;
					color: #FFFFFF;
				}

				.unibox {
					display: flex;
					flex-direction: row;
					justify-content: center;
					color: #FFFFFF;
				}

				.majbox {
					display: flex;
					flex-direction: row;
					justify-content: center;
					color: #FFFFFF;
				}
			}
		}

		.titlebox {
			display: flex;
			justify-content: center;
			align-items: center;
			height: 10vh;
			width: 100%;
			position: relative;
			top: -390rpx;

			.trade {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-around;
				text-align: center;
				//background-color: #007AFF;
				width: 600rpx;
				color: #808080;
				overflow: auto;
				font-size: 40rpx;
			}

			.trade view {
				margin-top: 20rpx;
				text-align: center;
				padding-left: 10upx;
				width: 30%;
				float: left;
			}

			.trade .texts.active {
				margin-top: 23rpx;
				border-bottom: 8upx solid #007AFF;
				font-size: 45rpx;
				font-weight: bold;
				color: #007AFF;
			}
		}

		.bigbox {
			//background-color: #007AFF;
			position: relative;
			top: -410rpx;

			.swiper-item1 {
				background-color: #F9F9F9;
				display: flex;

				.scroll-view1 {
					height: 100%;

					.my_evaluate {
						display: flex;
						flex-direction: column;
						padding: 20rpx;
						margin: 20rpx;
						border-radius: 8rpx;
						box-shadow: 0 0 10rpx 2rpx rgba($color: #000000, $alpha: 0.1);
						box-sizing: border-box;
						background: #FFFFFF;

						.title {
							width: 100%;
							//background-color: #2C405A;

							text {
								font-weight: bold;
								font-size: 35rpx;
							}
						}

						.headbox {
							display: flex;
							flex-direction: row;
							float: left;
							width: 100%;
							height: 140rpx;
							justify-content: space-between;
							align-items: center;
							position: relative;
							justify-content: flex-start;

							.head_image {
								//background-color: #2C405A;
								width: 100rpx;
								height: 100rpx;
								//overflow: hidden;
								margin-left: 10rpx;

								image {
									width: 100%;
									height: 100%;
									border-radius: 50%;
								}
							}

							.headcenter {
								display: flex;
								//background-color: #4CD964;
								height: 120rpx;
								flex-direction: column;
								width: 400rpx;
								margin-left: 10rpx;

								.head_name {
									//background-color: #FFFFFF;

									margin-top: 15rpx;
									font-size: 35rpx;
									color: #555555;
									//position: absolute; 
									//left: 80rpx;
									font-weight: bold;
								}

								.head_time {
									//background-color: #FFFFFF;

									margin-top: 15rpx;
									font-size: 30rpx;
									color: #999999;
								}
							}
						}

						.content {
							//background-color: #FFFFFF;
							//background-color: #007111;
							//display: flex;
							width: 630rpx;
							font-size: 25rpx;
							justify-content: center;
							//align-items: center;
							color: #555555;
							margin-left: 20rpx;
							overflow: hidden;
							word-break: break-all;
							text-overflow: ellipsis;
							display: -webkit-box;
							/** 对象作为伸缩盒子模型显示 **/
							-webkit-box-orient: vertical;
							/** 设置或检索伸缩盒对象的子元素的排列方式 **/
							-webkit-line-clamp: 5;
							//align-items: center;
						}

						.dynamicimage {
							display: flex;
							//background-color: #000000;
							flex-direction: row;
							//align-items: center;
							justify-content: center;
							margin-top: 20rpx;

							.image {

								align-items: center;
								height: 400rpx;
								width: 400rpx;
								border-radius: 10rpx;
							}
						}

						.dynamicimage2 {
							display: flex;
							//background-color: #000000;
							flex-direction: row;
							align-items: center;
							justify-content: center;
							margin-top: 20rpx;

							.image2 {
								//background-color: #007AFF;
								align-items: center;
								height: 300rpx;
								width: 300rpx;
								border-radius: 10rpx;
								margin-left: 10rpx;
							}
						}

						.dynamicimage3 {
							display: flex;
							//background-color: #000000;
							flex-wrap: wrap;
							flex-direction: row;
							align-items: center;
							//justify-content: center;
							align-items: flex-start;
							align-content: flex-start;
							margin-top: 20rpx;
							margin-left: 15rpx;

							.image3 {
								//background-color: #007AFF;
								align-items: center;
								height: 200rpx;
								width: 200rpx;
								border-radius: 10rpx;
								margin-left: 10rpx;
								margin-top: 10rpx;
							}
						}


						.dynamicimage4 {
							display: flex;
							//background-color: #000000;
							flex-wrap: wrap;
							flex-direction: row;
							align-items: flex-start;
							align-content: flex-start;
							justify-content: center;
							margin-top: 10rpx;

							.image4 {
								//background-color: #007AFF;
								margin-top: 10rpx;
								align-items: center;
								height: 300rpx;
								width: 300rpx;
								border-radius: 10rpx;
								margin-left: 10rpx;
							}
						}

						.tagbox {
							display: flex;
							flex-direction: row;
							height: 50rpx;
							width: 100%;
							//background-color: #007AFF;
							margin-top: 15rpx;
							justify-content: flex-start;
							align-items: center;

							.tag {
								display: flex;
								font-size: 20rpx;
								margin-left: 20rpx;
								padding-top: 5rpx;
								padding-bottom: 10rpx;
								padding-left: 10rpx;
								padding-right: 10rpx;
								color: #FFFFFF;
								height: 30rpx;
								border-radius: 20rpx;
								//align-items: center;
								//width: 100rpx;
								text-align: center;
								text-justify: center;
							}
						}

						.likecmt {
							margin-top: 30rpx;
							//background-color: #007AFF;
							height: 60rpx;
							width: 100%;
							display: flex;
							//flex: 1;
							//width: 200rpx;
							//margin-left: 200rpx;
							justify-content: flex-end;

							.likebox {
								display: flex;
								flex-direction: row;
								//background-color: #333333;
								height: 100%;
								width: 120rpx;

								image {
									height: 50rpx;
									width: 50rpx;
								}

								text {
									margin-top: 5rpx;
								}
							}

							.cmtbox {
								display: flex;
								flex-direction: row;
								//background-color: #4CD964;
								height: 100%;
								width: 120rpx;
							}

							image {
								height: 50rpx;
								width: 50rpx;
							}

							text {
								margin-top: 5rpx;
							}
						}
					}
				}
			}

			.swiper-item2 {
				background-color: #F9F9F9;
				display: flex;

				.scroll-view1 {
					
					
					.groupbox{
						display: flex;
						flex-direction: row;
						padding: 20rpx;
						margin-left: 30rpx;
						margin-right: 30rpx;
						margin-top: 10rpx;
						border-radius: 8rpx;
						box-shadow: 0 0 10rpx 2rpx rgba($color: #000000, $alpha: 0.1);
						box-sizing: border-box;
						background: #FFFFFF;
						justify-content: center;
						
						.logobox{
							height: 100rpx;
							width: 100rpx;
							
							image{
								height: 100rpx;
								width: 100rpx;
								border-radius: 100rpx;
							}
						}
						
						.universityname{
							font-weight: bold;
							display: flex;
							//justify-content: center;
							align-items: center;
							margin-left: 50rpx;
							font-size: 40rpx;
							
						}
					}
				}
			}
		}
	}
</style>
